<?php
/**
 * @package     Celtawebtickets component
 * @copyright   Copyright (C) 2012 CMExt Team http://www.cmext.vn/
 * @license     http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
 */

// No direct access
defined('_JEXEC') or die;

jimport('joomla.application.component.view');

class CeltawebticketsViewMailTemplates extends JView
{
	protected $items;
	protected $pagination;
	protected $state;
    
	public function display($tpl = null)
	{
		$this->items		= $this->get('Items');
		$this->pagination	= $this->get('Pagination');
		$this->state		= $this->get('State');
        
		// Check for errors.
		if(count($errors = $this->get('Errors')))
        {
			JError::raiseError(500, implode("\n", $errors));
			return false;
		}
        
		$this->addToolbar();
		parent::display($tpl);
	}

	protected function addToolbar()
	{
                require_once JPATH_COMPONENT.'/helpers/celtawebtickets.php';
		$canDo	= CeltawebticketsHelper::getActions();
                
                JToolBarHelper::title(JText::_('COM_CELTAWEBTICKETS_MANAGER_EMAIL'), 'celtawebtickets-mail');
                JToolBarHelper::back( 'COM_CELTAWEBTICKETS_HEADING_CPANEL', 'index.php?option=com_celtawebtickets' );
                JToolBarHelper::divider();
       
		if ($canDo->get('core.create')) {
			JToolBarHelper::addNew('mailtemplate.add');
		}
		if ($canDo->get('core.edit')) {
			JToolBarHelper::editList('mailtemplate.edit');
		}

		if ($canDo->get('core.delete')) {
                        JToolBarHelper::deleteList('mailtemplates.delete');
			JToolBarHelper::divider();
		}

		if ($canDo->get('core.admin')) {
			JToolBarHelper::preferences('com_celtawebtickets');
			JToolBarHelper::divider();
		}
        }
}

